#include "Sql_list.h"

int main(int argc, char const *argv[])
{
    Elemnt_data data[50] =
        {
            {.name = "刘备", .sex = "男", .grade = 60, .age = 18, .id = 1},
            {.name = "关羽", .sex = "男", .grade = 60, .age = 18, .id = 2},
            {.name = "张飞", .sex = "女", .grade = 60, .age = 18, .id = 3},
            {.name = "诸葛", .sex = "男", .grade = 60, .age = 18, .id = 4},
            {.name = "赵云", .sex = "男", .grade = 60, .age = 18, .id = 5},
            // {.name = "马超", .sex = "男", .grade = 60, .age = 18, .id = 6},
            // {.name = "祝融", .sex = "女", .grade = 60, .age = 18, .id = 7},
            // {.name = "小乔", .sex = "女", .grade = 60, .age = 18, .id = 8},
            // {.name = "大乔", .sex = "女", .grade = 60, .age = 18, .id = 9},
            //{.name = "貂蝉", .sex = "女", .grade = 60, .age = 18, .id = 10}
        };

    Sql_list stu;
    Sql_list *L = &stu;
    /*===================================== test =====================================*/
    Init_Sql_list(L); // 初始化stu

    for (size_t i = 0; i < 5; i++)
    {
        tail_insert_list(L, data[i]); // 插入
    }

    printf_Sql_list(L); // 遍历

    //====================================== 通过序号找信息 ======================================
    // int index = 0;
    // printf("请输入你要查找的序号:");
    // scanf("%d", &index);
    // printf("名字:%s 性别:%s 年龄:%d 学号:%d 成绩:%d\n", find_by_index(L, index)->name,
    //        find_by_index(L, index)->sex, find_by_index(L, index)->age,
    //        find_by_index(L, index)->id, find_by_index(L, index)->grade);

    //======================================== 末尾删除 ========================================
    // tail_del_list(L);
    // printf_Sql_list(L); // 遍历

    //====================================== 通过名字找序号 ======================================
    // char Name[20];
    // printf("请输入你要查找的名字:");
    // scanf("%s", Name);
    // printf("%d\n",find_by_name(L,Name));

    //====================================== 任意位置插入 ======================================
    // Elemnt_data data_in = {.name = "大乔", .sex = "女", .grade = 60, .age = 18, .id = 6};
    // pos_insert_list(L , 3 , data_in);
    // printf_Sql_list(L); // 遍历

    //====================================== 任意位置删除 ======================================
    pos_del_list(L,2);
    printf_Sql_list(L); // 遍历
    return 0;
}